package org.shindou09.easytagforpage.view.impl;

import java.io.IOException;
import java.io.Writer;

import org.shindou09.easytagforpage.Page;
import org.shindou09.easytagforpage.view.PageView;
import org.shindou09.easytagforpage.view.jsp.JspPageViewFactory;

public class JspPageViewImpl implements PageView{

	public final static String DEFAULT="org.shindou09.easytagforpage.view.jsp.impl.DefaultJspPageViewImpl";
	
	public final static String NUMBER="org.shindou09.easytagforpage.view.jsp.impl.NumberJspPageViewImpl";
	
	private String theme;
	
	public void getView(Page page, String pageUrl, Writer writer) {
		// TODO Auto-generated method stub
		String str=JspPageViewFactory.getJspPageView(theme).createJsp(page, pageUrl);
		try {
			writer.write(str);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void setTheme(String template) {
		// TODO Auto-generated method stub
		if(template==null || template.toLowerCase().trim().equals("default")){
			this.theme=DEFAULT;
		}else if(template.toLowerCase().trim().equals("number")){
			this.theme=NUMBER;
		}else{
			this.theme=template;
		}
	}

}
